import { defineStore } from "pinia";

export const userStoreX = defineStore("user", {
  state: () => ({
    user: sessionStorage.getItem("user")
      ? JSON.parse(sessionStorage.getItem("user")!)
      : {},
  }),
  actions: {
    changeUser(parmas: any) {
      if (parmas.username) {
        this.user = parmas;
      } else {
        sessionStorage.removeItem("user");
      }
    },
  },
});
